﻿Imports System.Data.SqlClient

Public Class frmUsuariosConectados
    Dim Bitacora As New clsActividad
    Dim Usuario As New clsUsuarioPrincipal

    Private Sub frmUsuariosConectados_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed
        Bitacora.RegistraActividad("Cerró a Usuarios Activos")
        Usuario.Ubicacion("Ventana Principal")
    End Sub
    Private Sub frmUsuariosConectados_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        ToolStrip1.Cursor = Cursors.Hand
        ToolStrip1.RenderMode = System.Windows.Forms.ToolStripRenderMode.System
        dgUsuarios.DefaultCellStyle.Font = New Font("Segoe UI", 10, FontStyle.Regular)

        Bitacora.RegistraActividad("Ingresó a Usuarios Activos")
        Usuario.Ubicacion("Usuarios Activos")

        CargaUsuarios()

    End Sub
    Sub CargaUsuarios()
        dgUsuarios.Rows.Clear()

        Dim cnConn As New SqlConnection
        Dim cmdBuscar As New SqlCommand
        Dim rdBuscar As SqlDataReader
        Dim strSql As String

        Try
            cnConn.ConnectionString = InitialConnection

            strSql = "Select * from UsuariosConectados"

            cmdBuscar.Connection = cnConn
            cmdBuscar.CommandText = strSql

            cnConn.Open()
            rdBuscar = cmdBuscar.ExecuteReader

            Do While rdBuscar.Read()
                dgUsuarios.Rows.Add(rdBuscar("Usuario").ToString.Trim, rdBuscar("Ubicacion").ToString.Trim, rdBuscar("Equipo").ToString.Trim)
            Loop
        Catch ex As Exception
            MessageBox.Show(ex.Message, "System Message", MessageBoxButtons.OK, MessageBoxIcon.Error)
        Finally
            If cnConn.State = ConnectionState.Open Then
                cnConn.Close()
            End If
        End Try

       
    End Sub

    Private Sub ToolStripButton1_Click(sender As System.Object, e As System.EventArgs) Handles ToolStripButton1.Click
       
        Close()

    End Sub
End Class